package org.MyToolsProject;

import java.io.File;
import java.io.FileInputStream;
import java.util.Base64;

public class CreateBase64Main {
    public static void main(String[] args) {

    }

    public static String readFile(String filePath) {
        String userPass = "";
        try {
            byte[] out = readFileInBytesToString(filePath);
            Base64.Encoder encoder = Base64.getEncoder();
            userPass = encoder.encodeToString(out).replaceAll("[\\s*\t\n\r]", "");
        } catch (Exception var8) {
            //LOG.error("machineUser get password failed : ", new Object[]{var8.getMessage()});
        }
        return userPass;
    }

    public static byte[] readFileInBytesToString(String filePath) throws Exception {
        File file = new File(filePath);
        Long filelength = file.length();
        byte[] filecontent = new byte[filelength.intValue()];
        if (file.exists()) {
            try {
                FileInputStream in = new FileInputStream(file);
                Throwable var6 = null;
                try {
                    if (in.read(filecontent) == -1) {
                       // LOG.error("read file failed", new Object[0]);
                    }
                } catch (Throwable var16) {
                    var6 = var16;
                    throw var16;
                } finally {
                    if (in != null) {
                        if (var6 != null) {
                            try {
                                in.close();
                            } catch (Throwable var15) {
                                var6.addSuppressed(var15);
                            }
                        } else {
                            in.close();
                        }
                    }

                }
            } catch (Exception var18) {
               // LOG.error("readFileInBytesToString failed: {}", new Object[]{var18.getMessage()});
                throw new Exception(var18);
            }
        }
        return filecontent;
    }
}